home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / PartMaker 4.4 / PartMaker Documents / Script Runner• / Script Runner•.rsrc / dFRK_5048 < prev    next >
Encoding:
Text File  |  1995-12-12  |  7.5 KB  |  251 lines

  1. /*------------------------------------------------------------------------------
  2.     File:        PaletteExt.cpp
  3.  
  4.     Contains:    Palette Extension implementation
  5.  
  6.     Written by:    Sue Dumont, Andrey Dolgachev
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. ------------------------------------------------------------------------------*/
  10.  
  11. #ifndef _EXCEPT_
  12. #include <Except.h>
  13. #endif
  14.  
  15. #ifndef _ODNEW_
  16. #include <ODNew.h>
  17. #endif 
  18.  
  19. #ifndef _ODNEWOBJ_
  20. #include <ODNewObj.h>
  21. #endif
  22.  
  23. // Notification that this is a SOM source file
  24. #define Samples_PaletteExt_Class_Source
  25.  
  26. // define underscore field names (ie. _fSelf)
  27. #define VARIABLE_MACROS
  28.  
  29. // -- PaletteExt Includes --
  30.  
  31. #ifndef SOM_Samples_PaletteExt_xih
  32. #include "PaletteExt.xih"
  33. #endif
  34.  
  35. // Needs to be customized for the specific owner part.
  36. #ifndef SOM_SampleCode_ScriptRunner_xh
  37. #include "ScriptRunner.xh"
  38. #endif
  39.  
  40. // -- OpenDoc Includes --
  41.  
  42. #ifndef SOM_ODExtension_xh
  43. #include <Extensn.xh>
  44. #endif
  45.  
  46.  
  47. #pragma segment PaletteExt
  48.  
  49. //====================================================================
  50. // PaletteExt - Common extension methods
  51. //====================================================================
  52.  
  53. //------------------------------------------------------------------------------
  54. // Method:        somInit
  55. //------------------------------------------------------------------------------
  56. SOM_Scope    void
  57. SOMLINK        PaletteExt__somInit(Samples_PaletteExt *somSelf)
  58. {
  59.     Samples_PaletteExtMethodDebug("PaletteExt","somInit");
  60.  
  61.     // somInit and somUninit methods behave like C++ constructors in that the
  62.     // inherited methods are called automatically.
  63.     // Thus, there is no need to call the parent class' somInit or somUninit.
  64.     
  65.     // There is also no need to set instance variables to zero/NULL
  66.     // since SOM guarantees that a newly constructed object is zeroed.
  67. }
  68.  
  69. //------------------------------------------------------------------------------
  70. // Method:        somUninit
  71. //------------------------------------------------------------------------------
  72. SOM_Scope    void
  73. SOMLINK        PaletteExt__somUninit(Samples_PaletteExt *somSelf)
  74. {
  75.     Samples_PaletteExtMethodDebug("PaletteExt","somUninit");
  76. }
  77.  
  78. //------------------------------------------------------------------------------
  79. // Method:        Acquire
  80. //------------------------------------------------------------------------------
  81. SOM_Scope    void
  82. SOMLINK        PaletteExt__Acquire(Samples_PaletteExt *somSelf, Environment *ev)
  83. {
  84.     Samples_PaletteExtMethodDebug("PaletteExt","PaletteExt__Acquire");
  85.  
  86.     SOM_TRY
  87.         Samples_PaletteExt_parent_ODExtension_Acquire(somSelf, ev);
  88.     SOM_CATCH_ALL
  89.     SOM_ENDTRY
  90. }
  91.  
  92. //------------------------------------------------------------------------------
  93. // Method:        Release
  94. //------------------------------------------------------------------------------
  95. SOM_Scope    void
  96. SOMLINK        PaletteExt__Release(Samples_PaletteExt *somSelf, Environment *ev)
  97. {
  98.     Samples_PaletteExtMethodDebug("PaletteExt","Release");
  99.  
  100.     SOM_TRY
  101.         Samples_PaletteExt_parent_ODExtension_Release(somSelf, ev);
  102.     SOM_CATCH_ALL
  103.     SOM_ENDTRY
  104. }
  105.  
  106. //------------------------------------------------------------------------------
  107. // Method:        InitExtension
  108. //
  109. // Description:
  110. //------------------------------------------------------------------------------
  111. SOM_Scope void  SOMLINK PaletteExt__InitExtension(Samples_PaletteExt *somSelf,
  112.                                 Environment *ev, ODObject* base)
  113. {
  114.     Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
  115.     Samples_PaletteExtMethodDebug("PaletteExt","InitExtension");
  116.  
  117.     SOM_TRY
  118.         Samples_PaletteExt_parent_ODExtension_InitExtension(somSelf, ev, base);
  119.  
  120.         _fOwner = (SampleCode_ScriptRunner*) ((ODPart*)base)->GetRealPart(ev);
  121.         ((ODPart*)base)->ReleaseRealPart(ev);
  122.     SOM_CATCH_ALL
  123.     SOM_ENDTRY
  124. }
  125.  
  126. //------------------------------------------------------------------------------
  127. // Method:        Show
  128. //
  129. // Description:    Tell the owner part to show the palette.
  130. //------------------------------------------------------------------------------
  131. SOM_Scope    void
  132. SOMLINK        PaletteExt__Show(Samples_PaletteExt *somSelf, Environment *ev)
  133. {
  134.     Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
  135.     Samples_PaletteExtMethodDebug("PaletteExt","Show");
  136.        
  137.        SOM_TRY
  138.            _fOwner->ShowPalette(ev);
  139.     SOM_CATCH_ALL
  140.     SOM_ENDTRY
  141. }
  142.  
  143. //------------------------------------------------------------------------------
  144. // Method:        Hide
  145. //
  146. // Description:    Tell the owner part to hide the palette.
  147. //------------------------------------------------------------------------------
  148. SOM_Scope    void
  149. SOMLINK        PaletteExt__Hide(Samples_PaletteExt *somSelf, Environment *ev)
  150. {
  151.     Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
  152.     Samples_PaletteExtMethodDebug("PaletteExt","Hide");
  153.  
  154.     SOM_TRY
  155.            _fOwner->HidePalette(ev);    
  156.     SOM_CATCH_ALL
  157.     SOM_ENDTRY
  158. }
  159.  
  160. //------------------------------------------------------------------------------
  161. // Method:        IsPaletteVisible
  162. //
  163. // Description:    Call the owner part to determine whether the palette
  164. //                is visible or not, and return the result.
  165. //------------------------------------------------------------------------------
  166. SOM_Scope    ODBoolean
  167. SOMLINK        PaletteExt__IsPaletteVisible(Samples_PaletteExt *somSelf, Environment *ev)
  168. {
  169.       Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
  170.     Samples_PaletteExtMethodDebug("PaletteExt","IsPaletteVisible");
  171.  
  172.     ODBoolean    result;
  173.  
  174.     SOM_TRY
  175.         result = _fOwner->IsPaletteVisible(ev);
  176.     SOM_CATCH_ALL
  177.         result = kODFalse;
  178.     SOM_ENDTRY
  179.     
  180.     return result;
  181. }
  182.  
  183. //------------------------------------------------------------------------------
  184. // Method:        Move
  185. //
  186. // Description:    The corresponding method of the owner part is called to move
  187. //                 the palette to the specified top-left coordinate.
  188. //                 The result indicates whether the move was successful or not.
  189. //------------------------------------------------------------------------------
  190. SOM_Scope    ODBoolean
  191. SOMLINK        PaletteExt__Move(Samples_PaletteExt *somSelf, Environment *ev, 
  192.                                 ODPoint* topleft)
  193. {
  194.     Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
  195.     Samples_PaletteExtMethodDebug("PaletteExt","Move");
  196.  
  197.     ODBoolean    result;
  198.  
  199.     SOM_TRY
  200.         result = _fOwner->MovePalette(ev, topleft);
  201.     SOM_CATCH_ALL
  202.         result = kODFalse;
  203.     SOM_ENDTRY
  204.     
  205.     return result;
  206. }
  207.  
  208. //------------------------------------------------------------------------------
  209. // Method:        GetLocation
  210. //
  211. // Description:    This method calls the owner part to obtain the top-left 
  212. //                coordinate of the scripting palette.
  213. //------------------------------------------------------------------------------
  214. SOM_Scope    ODPoint*
  215. SOMLINK        PaletteExt__GetLocation(Samples_PaletteExt *somSelf,Environment *ev)
  216. {
  217.     Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
  218.     Samples_PaletteExtMethodDebug("PaletteExt","GetLocation");
  219.  
  220.     ODPoint* point;
  221.     
  222.     SOM_TRY
  223.         point = _fOwner->GetPaletteLocation(ev);
  224.     SOM_CATCH_ALL
  225.         point = kODNULL;
  226.     SOM_ENDTRY
  227.     
  228.     return point;
  229. }
  230.  
  231. //------------------------------------------------------------------------------
  232. // Method:        SetClient
  233. //
  234. // Description:    This method is called by the client part when switching
  235. //                from one part to another part of its own kind. It is 
  236. //                necessary to call this method to allow the sharing of
  237. //                the palette window.
  238. //------------------------------------------------------------------------------
  239. SOM_Scope    void
  240. SOMLINK        PaletteExt__SetClient(Samples_PaletteExt *somSelf,
  241.                             Environment *ev, ODPart* client)
  242. {
  243.     Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
  244.     Samples_PaletteExtMethodDebug("PaletteExt","PaletteExt__SetClient");
  245.  
  246.     SOM_TRY
  247.         _fOwner->SetClient(ev, client);
  248.     SOM_CATCH_ALL
  249.     SOM_ENDTRY
  250. }
  251.